package goftp

type ConnectFunc func(*ConnectCfg)
type ConnectFuncs []ConnectFunc

func (this ConnectFuncs) apply(cfg *ConnectCfg) {
	for _, f := range this {
		f(cfg)
	}
}
func WithAddress(address string) ConnectFunc {
	return func(cfg *ConnectCfg) {
		cfg.Address = address
	}
}
func WithUserName(userName string) ConnectFunc {
	return func(cfg *ConnectCfg) {
		cfg.UserName = userName
	}
}
func WithPwd(pwd string) ConnectFunc {
	return func(cfg *ConnectCfg) {
		cfg.Pwd = pwd
	}
}
func NewCfg(fn ...ConnectFunc) *ConnectCfg {
	cfg := new(ConnectCfg)
	ConnectFuncs(fn).apply(cfg)
	return cfg
}
